<template>
  <el-dialog
    title="修改子单追踪号"
    :modal="false"
    :visible.sync="centerDialogVisible"
    width="50%"
    center
  >
    <div>
      <el-table
        :data="tableData"
        style="width: 100%"
        height="250"
        @row-click="handleCurrentChange"
      >
        <el-table-column fixed prop="subWaybillNo" label="子单号" width="250">
        </el-table-column>
        <el-table-column prop="trackNumber" label="追踪号" width="250">
          <template slot-scope="scope">
            <el-input
              size="small"
              v-model="scope.row.trackNumber"
              v-show="scope.row.id"
              placeholder="请输入内容"
            ></el-input>
            <span v-show="!scope.row.id">{{ scope.row.trackNumber }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="boxNo" label="外箱号" width="250">
        </el-table-column>
        <el-table-column prop="clearanceNo" label="清关号" width="250">
        </el-table-column>
      </el-table>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="centerDialogVisible = false">取 消</el-button>
      <el-button
        type="primary"
        @click="editSubwaybillTrackNo"
        v-loading.fullscreen.lock="fullscreenLoading"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>

<script>
import { ajax } from "@/store/yg/common/utils";
import axios from "axios";
import * as constant from "@/store/yg/common/constant";
import { m } from "@/store/yg/common/local";
export default {
  props: {
    tableData: {
      type: Array,
      default: function(params) {
        return [{}];
      }
    },
    data: {
      type: Object,
      default: function() {
        return {};
      }
    }
  },
  data() {
    return {
      fullscreenLoading: false,
      centerDialogVisible: false

      // tableData: [{
      //     id:0,
      //     subWaybillNo: 'DDS',
      //     trackNumber: '王小虎',
      //     boxNo: '上海',
      //     clearanceNo: '普陀区',
      //   }, {
      //     id:0,
      //     subWaybillNo: 'BFDF',
      //     trackNumber: '王小虎',
      //     boxNo: '上海',
      //     clearanceNo: '普陀区',
      //   }]
    };
  },

  methods: {
    //修改子单追踪号
    editSubwaybillTrackNo() {
      var param = {};
      param = this.tableData;
      this.fullscreenLoading = true;
      ajax("editSubwaybillTrackNo", param).then(
        res => {
          this.fullscreenLoading = false;
          if (res.code != 200) {
            if (null != res.message) {
              this.$message.error(m(res.message));
            } else {
              this.$message.error("修改失败!");
            }
          } else {
            this.$message.success("修改成功!");
            this.centerDialogVisible = false;
          }
        },
        error => {
          console.log(error);
        }
      );
    },

    handleCurrentChange(row, event, column) {},
    handleEdit(index, row) {},
    handleDelete(index, row) {}
  },
  mounted() {}
};
</script>

<style></style>
